﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace WebOS.Web.Controllers
{
    public class BookController : Controller
    {
        //
        // GET: /Book/

        public IList<Dept> depts=new List<Dept>();

        public BookController()
        {
            for (int i = 0; i < 8; i++)
            {
                IList<User> users = new List<User>();
                for (int j = 0; j < 10; j++)
                {
                    users.Add(new User { Name = "用户" + i + j, ENName = "User" + i + j, Phone = "10086" });
                }
                depts.Add(new Dept { ID=i, Name="部门"+i,Users=users });
            }
        }

        public ActionResult Index()
        {
            return View();
        }

        public JsonResult GetAllUsers()
        {
            return Json(depts,JsonRequestBehavior.AllowGet);
        }

    }

    public class Dept {
        public long ID { get; set; }
        public string Name { get; set; }
        public IEnumerable<User> Users { get; set; }
    }
    public class User {
        public string Name { get; set; }
        public string ENName { get; set; }
        public string Phone { get; set; }
    }
}
